<?php

namespace App\Listeners;

use App\Events\SmsSent;
use App\Models\SmsLog;
use App\Services\IMobileService;
use Illuminate\Http\Request;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Log;
use Symfony\Component\HttpFoundation\IpUtils;

class SmsSentListener
{

    private $mobileService;

    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct(IMobileService $mobileService)
    {
        $this->mobileService = $mobileService;
    }

    /**
     * Handle the event.
     *
     * @param  SmsSent  $event
     * @return void
     */
    public function handle(SmsSent $event)
    {
        Log::info('send sms message',[
            $event->phoneNum,
            $event->message,
            $event->result,
        ]);
        return $this->mobileService->smsLog($event->phoneNum,$event->message,$event->code,$event->result);
    }
}
